package com.sonicvision.resourcetracker.employee;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Repository;

import com.sonicvision.resourcetracker.exceptions.DAOException;

@Repository
public class EmployeeExperienceJPAImpl implements EmployeeExperienceDAO {
	
	@PersistenceContext(unitName="resourcetracker")
	private EntityManager em; 

	@Override
	public void addEmpExp(EmployeeExperience employeeExp) throws DAOException {
		em.persist(employeeExp);
	}

	@Override
	public void updateEmpExp(EmployeeExperience employee_Experience_Id) throws DAOException {
		   
		    if (employee_Experience_Id == null){			
			throw new DAOException ("Employee Document not found");			
		    } else {			   
			em.merge(employee_Experience_Id);
		}	
		
		
	}

	@Override
	public void deleteEmpExp(EmployeeExperience employee_Experience_Id) throws DAOException {
		
		    if (employee_Experience_Id == null){			
			throw new DAOException ("Employee Document not found");			
		    } else {			   
			em.remove(employee_Experience_Id);
		 }
		
	}

}
